package com.googlecode.jerato.library.view;

import com.googlecode.jerato.core.FunctionParameters;
import com.googlecode.jerato.core.FunctionTransfer;
import com.googlecode.jerato.core.view.ViewFunction;
import com.googlecode.jerato.core.view.ViewParameters;
import com.googlecode.jerato.core.view.ViewTransfer;

public abstract class ViewFunctionImpl implements ViewFunction{

	public void call(FunctionTransfer trans, FunctionParameters input,
			FunctionParameters output) {
		if(!(trans instanceof ViewTransfer)
			|| !(input instanceof ViewParameters)
			|| !(output instanceof ViewParameters))
		{
			trans = new ViewTransferImpl(trans);
			input = new ViewParametersImpl(input);
			output = new ViewParametersImpl(output);
		}
		execute((ViewTransfer)trans, (ViewParameters)input, (ViewParameters)output);
		((ViewParameters)output).flushParent();
		((ViewTransfer)trans).flushParent();
	}

}
